package model;


import java.util.LinkedList;
import java.util.Observable;

public class AdapterQueue<E> extends Observable implements QueueADT<E>{
	
	protected LinkedList<E> S = new LinkedList<E>();

	
	public int size(){
	//returns size of the queue	
		return S.size();			
	}
	
	public boolean isEmpty(){
	//return true if queue is empty	
		return S.size() == 0;
		
	}
	public E front() throws EmptyQueueException{
	// returns the element from the head of the queue but does not remove it				
		if (S.isEmpty()){
			throw new EmptyStackException
			("Queue is empty. Cannot obtain an element");}	
		return S.peek(); 
			
	}
	public void enqueue(E element){
	// Adds an element to the queue	
		S.add(element);
			
	}
		
	public E dequeue() throws EmptyQueueException{
	// removes the element at the head of the queue	
		E element;
		if (S.isEmpty()){
			throw new EmptyQueueException
			("Empty Stack: Cannot pop");}
		
		element = S.poll();
		
		return element;
	}
	
	public void update() {
		this.setChanged();
		this.notifyObservers();
	}
}
